<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Insert title here</title>
</head>

<script>
    
  function cat(name,color)
  {
    this.name=name;
    this.color=color;
    cat.prototype.typename="猫科动物";
    cat.prototype.recall=function()
    {
      alert("我是一只猫");
    }
    
  }

  function test()
  {


      var cat1=new cat("tom","yellow");
      var cat2=new cat("kafei","white");
    //  cat1.recall();
     // cat2.recall();
      alert(cat1.typename);
      //两个函数公用一个recall函数实例
      alert("cat1.recall==cat2.recall is true?" +cat1.recall==cat2.recall);
      alert("cat.prototype.isProtypeOf(cat1) is true? "+cat.prototype.isPrototypeOf(cat1));
       //hasownproperty 函数用来判断 某个属性是否是自己的 还是继承自父类
      alert("cat1.hasOwnProperty(name)"+cat1.hasOwnProperty("name")); // true
      alert("cat1.hasOwnProperty(typename)"+cat1.hasOwnProperty("typename")); // false

  }


</script>
<body>
<input type="button" value="测试 使用构造函数 构造对象" onclick="test()">


</body>
</html>